package com.itheima.mydate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class birthday {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的生日：");
        String birthday = sc.next();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = simpleDateFormat.parse(birthday);
        //获取到的是生日日期对应的毫秒值
        long birth = date1.getTime();

        //获取当前系统时间对应的毫秒值
        Date date2 = new Date();
        long now = date2.getTime();

        long age = (now - birth) / 1000L / 60 / 60 / 24 / 365;
        long day = (now - birth) / 1000L / 60 / 60 / 24;
        System.out.println("您的年龄为" + age + "岁!");
        System.out.println("您已经活了" + day + "天!");

    }
}
